package com.zjp.mg.service;

import org.bson.json.JsonMode;
import org.bson.json.JsonWriterSettings;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;

public class DataMain {

    public static void main(String[] args) {

        Query select = new Query();
        select.fields().include("userName").include("mobile");
        select.addCriteria(new Criteria("userName").is("66788"));
        select.addCriteria(new Criteria("mobile").is("789"));
        select.addCriteria(new Criteria("age").gte(30));
        select.with(Sort.by(Sort.Direction.DESC, "_id"));
        select.skip(50);
        select.limit(50);
        System.out.println(select.getFieldsObject().toJson(JsonWriterSettings.builder().outputMode(JsonMode.SHELL).build()));
        System.out.println(select.getQueryObject().toJson(JsonWriterSettings.builder().outputMode(JsonMode.SHELL).build()));
        System.out.println(select.getSortObject().toJson(JsonWriterSettings.builder().outputMode(JsonMode.SHELL).build()));
        System.out.println(select.toString());
    }

}

